<template>
  <section id="section">
    <div class="left" @click="back">
      <i class="el-icon-d-arrow-left"></i>
    </div>
    <main>
      <!-- <iframe width="100%" :src="filelink" v-if="filelink" name="yulan" height="100%" /> -->
      <div class="main_right">
        <div class="main_head rightBorder">基础装配工艺内容</div>
        <div class="main_content rightBorder">
          <div class="main">
            <div class="head rightBorder">
              工步内容
            </div>
            <div class="content rightBorder">
              {{ yulanData.stepContent }}
            </div>
          </div>
          <div class="main">
            <div class="head">
              工步图片
            </div>
            <div class="content">
              <img @click="dialogTableVisible = true" :src="yulanData.stepPic" alt="" />
            </div>
          </div>
        </div>
      </div>
      <div class="main_left">
        <div class="main_head flex">
          <div class="main_head1 rightBorder">定制装配内容</div>
          <div class="main_head2">工夹量辅清单</div>
        </div>
        <div class="main_content">
          <div class="main">
            <div class="head rightBorder">
              更改内容
            </div>
            <div class="content rightBorder">
              {{ yulanData.modifyContent }}
            </div>
          </div>
          <div class="main">
            <div class="content" id="heightAotu">
              <div class="row">
                <div class="lable rightBorder">工程量辅编号</div>
                <div class="value">名称</div>
              </div>
              <div class="row" v-for="(item, index) in yulanData.detailList" :key="index">
                <div class="lable rightBorder">{{ item.key }}</div>
                <div class="value">{{ item.value }}</div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </main>
    <div class="right" @click="next">
      <i class="el-icon-d-arrow-right"></i>
    </div>
    <el-dialog title="" :visible.sync="dialogTableVisible" fullscreen>
      <img :src="yulanData.stepPic" alt="" />
    </el-dialog>
  </section>
</template>

<script>
import storage from 'js-storage';

export default {
  props: {
    yulanData: {
      type: Object,
      default: () => {},
    },
    tableData: {
      type: Object,
      default: () => {},
    },
    loading: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {
      dialogTableVisible: false,
      stepIndex: 0,
    };
  },
  created() {
    this.stepIndex = storage.localStorage.get('stepIndex');
  },
  methods: {
    // 上一步
    back() {
      if (this.loading) {
        this.$message.error('请稍后，数据请求中');
        return;
      }
      if (this.stepIndex <= 0) {
        this.$message.error('已经是第一步了');
        return;
      }
      this.stepIndex--;
      storage.localStorage.set('stepIndex', this.stepIndex); // 进入第一步
    },
    // 下一步
    next() {
      if (this.loading) {
        this.$message.error('请稍后，数据请求中');
        return;
      }
      if (this.stepIndex >= this.tableData.workStepList.length - 1) {
        this.$message.error('已经是最后一步了');
        return;
      }
      this.stepIndex++;
      storage.localStorage.set('stepIndex', this.stepIndex); // 进入第一步
    },
  },
};
</script>

<style lang="scss">
#section {
  width: 98%;
  height: 100%;
  margin: 0 auto;
  display: flex;
  .el-dialog__body {
    display: flex;
    justify-content: center;
  }
  .left,
  .right {
    width: 2%;
    background: rgba(0, 0, 0, 0.116);
    font-size: 26px;
    cursor: pointer;
    line-height: 70vh;
    text-align: center;
    color: cadetblue;
    &:hover {
      color: #fff;
      background: rgba(0, 0, 0, 0.301);
    }
  }
  main {
    height: 100%;
    width: 98%;
    // iframe {
    //   height: 100%;
    // }
    display: flex;
    border-right: 1px solid #000;
    border-left: 1px solid #000;
    & > div {
      flex: 1;
      height: 100%;
    }
    .main_head {
      height: 40px;
      line-height: 40px;
      text-align: center;
      font-weight: 600;
      &.flex {
        display: flex;
      }
      & > div {
        flex: 1;
      }
    }
    .main_content {
      height: calc(100% - 40px);
      border-top: 1px solid #000;
      display: flex;
      & > div {
        flex: 1;
        height: 100%;
      }
      .head {
        height: 30px;
        line-height: 30px;
        text-align: center;
        border-bottom: 1px solid #000;
      }
      .content {
        height: calc(100% - 30px);
        padding: 10px;
        img {
          cursor: pointer;
        }
        .row {
          display: flex;
          & > div {
            flex: 1;
            border-bottom: 1px solid #000;
            height: 30px;
            line-height: 30px;
            text-align: center;
          }
        }
      }
    }
  }
  .rightBorder {
    border-right: 1px solid #000;
  }
  #heightAotu {
    height: 100%;
    overflow: auto;
    padding: 0;
  }
}
</style>
